package com.peace.hospital.opdept.service.outpatientdept.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.peace.hospital.entity.outpatientdept.Chargingitems;
import com.peace.hospital.opdept.mapper.outpatientdept.ChargingitemsMapper;
import com.peace.hospital.opdept.service.outpatientdept.IChargingitemsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 处方表 服务实现类
 * </p>
 *
 * @author 谢晓峰
 * @since 2019-11-11
 */
@Service
public class ChargingitemsServiceImpl extends ServiceImpl<ChargingitemsMapper, Chargingitems> implements IChargingitemsService {
    @Autowired
    private ChargingitemsMapper chargingitemsMapper;
    @Override
    public Integer addChargingitems(Chargingitems chargingitems) {
        System.out.println(chargingitems);
        return chargingitemsMapper.addChargingitems(chargingitems);
    }

    /**根据病人id查询挂号检查费用
     * @return*/
    @Override
    public List<Chargingitems> selectChargingitemsByPid(Integer pid) {
        List<Chargingitems> chargingitems = chargingitemsMapper.selectChargingitemsByPid(pid);
        return chargingitems;
    }

    @Override
    public Double selectChargpriceByPid(Integer pid) {
        List<Double> doubles = chargingitemsMapper.selectChargpriceByPid(pid);
        Double count = 0.0;
        for (Double aDouble : doubles) {
            count+=aDouble;
        }
        return count;
    }
}
